package com.dkd.flow.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.flow.domain.EProcessGroup;
import com.dkd.flow.service.IEProcessGroupService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;
/**
 * 流程分组Controller
 *
 * @author itheima
 * @date 2025-01-26
 */
@Api(tags = "流程分组Controller")
@RestController
@RequestMapping("/flow/group")
public class EProcessGroupController extends BaseController {
    @Autowired
    private IEProcessGroupService eProcessGroupService;
    /**
     * 查询流程分组列表
     */
    @ApiOperation("查询流程分组列表")
    @PreAuthorize("@ss.hasPermi('flow:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(EProcessGroup eProcessGroup) {
        startPage();
        List<EProcessGroup> list = eProcessGroupService.selectEProcessGroupList(eProcessGroup);
        return getDataTable(list);
    }
    /**
     * 导出流程分组列表
     */
    @ApiOperation("导出流程分组列表")
    @PreAuthorize("@ss.hasPermi('flow:group:export')")
    @Log(title = "流程分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EProcessGroup eProcessGroup) {
        List<EProcessGroup> list = eProcessGroupService.selectEProcessGroupList(eProcessGroup);
        ExcelUtil<EProcessGroup> util = new ExcelUtil<EProcessGroup>(EProcessGroup.class);
        util.exportExcel(response,
                list,
                "流程分组数据");
    }
    /**
     * 获取流程分组详细信息
     */
    @ApiOperation("获取流程分组详细信息")
    @PreAuthorize("@ss.hasPermi('flow:group:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID) {
        return success(eProcessGroupService.selectEProcessGroupByID(ID));
    }
    /**
     * 新增流程分组
     */
    @ApiOperation("新增流程分组")
    @PreAuthorize("@ss.hasPermi('flow:group:add')")
    @Log(title = "流程分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EProcessGroup eProcessGroup) {
        Integer result = eProcessGroupService.insertEProcessGroup(eProcessGroup);
        return toAjax(result);
    }
    /**
     * 修改流程分组
     */
    @ApiOperation("修改流程分组")
    @PreAuthorize("@ss.hasPermi('flow:group:edit')")
    @Log(title = "流程分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EProcessGroup eProcessGroup) {
        return toAjax(eProcessGroupService.updateEProcessGroup(eProcessGroup));
    }
    /**
     * 删除流程分组
     */
    @ApiOperation("删除改流程分组")
    @PreAuthorize("@ss.hasPermi('flow:group:remove')")
    @Log(title = "流程分组", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs) {
        return toAjax(eProcessGroupService.deleteEProcessGroupByIDs(IDs));
    }
}
